
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.inline {
  background-color: #f7f7f7;
  border:solid 1px #B0B0B0;
}
.error {
	font-weight: bold;
	color: #FF0000;
}
.warning {
	font-weight: bold;
}
.message {
	font-style: italic;
}
.source, .output, .warning, .error, .message {
	padding: 0 1em;
  border:solid 1px #F7F7F7;
}
.source {
  background-color: #f5f5f5;
}
.left {
  text-align: left;
}
.right {
  text-align: right;
}
.center {
  text-align: center;
}
.hl.num {
  color: #AF0F91;
}
.hl.str {
  color: #317ECC;
}
.hl.com {
  color: #AD95AF;
  font-style: italic;
}
.hl.opt {
  color: #000000;
}
.hl.std {
  color: #585858;
}
.hl.kwa {
  color: #295F94;
  font-weight: bold;
}
.hl.kwb {
  color: #B05A65;
}
.hl.kwc {
  color: #55aa55;
}
.hl.kwd {
  color: #BC5A65;
  font-weight: bold;
}
</style>
  <script src="https://yihui.name/media/js/center-images.js"></script>
  <title>A Report Generated by knitr</title>
</head>
<body>

  <p>This report is automatically generated with the R
    package <a href="https://urldefense.com/v3/__https://yihui.name/knitr/__;!!KwNVnqRv!Qe-exEu_89J5vvEI1u-pbcrXYGLK45EjLOfXuHezEI1gG0Ck0tDXhU1bTDF12vU$"><strong>knitr</strong></a>
    (version <code class="knitr inline">1.31</code>)
    by .</p>

<div class="chunk" id="auto-report"><div class="rcode"><div class="source"><pre class="knitr r"><span class="hl com">##################</span>
<span class="hl com">#### ANALYSES ####</span>
<span class="hl com">##################</span>

<span class="hl com"># setwd(&quot;/Users/oyvindskorge/Dropbox/Papers/Giani-Hope-Skorge/7-Replication/&quot;)</span>

<span class="hl com">#### SETTINGS FOR THE ANALYSES ####</span>

<span class="hl com"># Please change the cores argument to the number of </span>
<span class="hl com"># cores on your computer</span>
<span class="hl std">v.cores</span> <span class="hl kwb">&lt;-</span> <span class="hl num">4</span>
<span class="hl std">v.parallel</span> <span class="hl kwb">&lt;-</span> <span class="hl num">TRUE</span>

<span class="hl com"># 10,000 bootstraps</span>
<span class="hl std">v.boots</span> <span class="hl kwb">&lt;-</span> <span class="hl num">10000</span>

<span class="hl com">#### SETUP ####</span>

<span class="hl kwa">if</span> <span class="hl std">(</span><span class="hl opt">!</span><span class="hl kwd">require</span><span class="hl std">(pacman)) {</span>
  <span class="hl kwd">install.packages</span><span class="hl std">(</span><span class="hl str">&quot;pacman&quot;</span><span class="hl std">)</span>
  <span class="hl kwd">require</span><span class="hl std">(pacman)</span>
<span class="hl std">}</span>

<span class="hl kwd">p_load</span><span class="hl std">(data.table,estimatr,lfe,</span>
       <span class="hl std">tidyverse, sjlabelled, sjmisc,</span>
       <span class="hl std">swfscMisc, mgcv, devtools,</span> <span class="hl kwc">update</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">)</span>

<span class="hl com"># inteflex version &gt;=1.1.3 needed for the analyses,</span>
<span class="hl com"># which can be installed by running the following line:</span>
<span class="hl com"># devtools::install_github(&quot;xuyiqing/interflex&quot;)</span>
<span class="hl kwd">p_load</span><span class="hl std">(interflex,</span> <span class="hl kwc">install</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span> <span class="hl kwc">update</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">)</span>

<span class="hl kwd">source</span><span class="hl std">(</span><span class="hl str">&quot;utils.r&quot;</span><span class="hl std">)</span>

<span class="hl com">#### DATA ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">sjlabelled</span><span class="hl opt">::</span><span class="hl kwd">read_data</span><span class="hl std">(</span><span class="hl str">&quot;ESSgenderUpdate2.dta&quot;</span><span class="hl std">)</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">Bad_jobZ</span> <span class="hl std">=</span> <span class="hl kwd">scale</span><span class="hl std">(Bad_job))</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">set_labels</span><span class="hl std">(Female,</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Men&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Women&quot;</span><span class="hl std">))</span>

<span class="hl std">dt.w</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">filter</span><span class="hl std">(Female</span><span class="hl opt">==</span><span class="hl num">2</span><span class="hl std">)</span>

<span class="hl std">dt.m</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">filter</span><span class="hl std">(Female</span><span class="hl opt">==</span><span class="hl num">1</span><span class="hl std">)</span>

<span class="hl com">#### MAIN ANALYSIS ####</span>

<span class="hl com">#### Setup ####</span>

<span class="hl std">v.z</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Age&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Age_sq&quot;</span><span class="hl std">,</span><span class="hl str">&quot;gender_share&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Child&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Minority&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Immigrant&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Domicile&quot;</span><span class="hl std">,</span>
  <span class="hl str">&quot;Education&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Income&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Income_sq&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Job&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Unemployed&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Unemployed_partner&quot;</span><span class="hl std">,</span>
  <span class="hl str">&quot;Religiosity&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Interviewe_Female&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Interfere&quot;</span><span class="hl std">)</span>
<span class="hl std">v.zp</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(v.z,</span><span class="hl str">&quot;eduParentsDiff&quot;</span><span class="hl std">,</span><span class="hl str">&quot;emp14Diff&quot;</span><span class="hl std">)</span>
<span class="hl std">v.zo</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(v.z,</span><span class="hl str">&quot;Job_diff&quot;</span><span class="hl std">)</span>

<span class="hl std">v.z.s</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Age&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Age_sq&quot;</span><span class="hl std">,</span><span class="hl str">&quot;gender_share&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Child&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Minority&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Immigrant&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Domicile&quot;</span><span class="hl std">,</span>
         <span class="hl str">&quot;Income&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Income_sq&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Job&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Unemployed&quot;</span><span class="hl std">,</span>
         <span class="hl str">&quot;Religiosity&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Interviewe_Female&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Interfere&quot;</span><span class="hl std">)</span>
<span class="hl std">v.zp.s</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(v.z.s,</span><span class="hl str">&quot;eduParentsDiff&quot;</span><span class="hl std">,</span><span class="hl str">&quot;emp14Diff&quot;</span><span class="hl std">)</span>

<span class="hl std">dt.w</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt.w</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">select</span><span class="hl std">(</span><span class="hl kwd">all_of</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Bad_jobZ&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span><span class="hl str">&quot;country&quot;</span><span class="hl std">,</span><span class="hl str">&quot;cntry&quot;</span><span class="hl std">,</span><span class="hl str">&quot;wgt&quot;</span><span class="hl std">,</span>
           <span class="hl kwd">unique</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(v.zp,v.zo)))))</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate_at</span><span class="hl std">(v.zp, arm</span><span class="hl opt">::</span><span class="hl std">rescale)</span>

<span class="hl std">dt.m</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt.m</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">select</span><span class="hl std">(</span><span class="hl kwd">all_of</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Bad_jobZ&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span><span class="hl str">&quot;country&quot;</span><span class="hl std">,</span><span class="hl str">&quot;cntry&quot;</span><span class="hl std">,</span><span class="hl str">&quot;wgt&quot;</span><span class="hl std">,</span>
                  <span class="hl kwd">unique</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(v.zp,v.zo)))))</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate_at</span><span class="hl std">(v.zp, arm</span><span class="hl opt">::</span><span class="hl std">rescale)</span>


<span class="hl com">#### Results for Figure 2. Interflex: with covariates ####</span>

<span class="hl std">ix.kern.z.w</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.w,</span>
                         <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">Z</span><span class="hl std">=v.z,</span>
                         <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                         <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                         <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                         <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                         <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                         <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                         <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                         <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                         <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 12 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.z.w,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_z_w.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.z.w &lt;- readRDS(&quot;ix_kern_z_w.rds&quot;)</span>
<span class="hl com"># ix.kern.z.w$t.test.diffs</span>
<span class="hl com"># ix.kern.z.w$graph</span>

<span class="hl std">ix.kern.z.m</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.m,</span>
                         <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">Z</span><span class="hl std">=v.z,</span>
                         <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                         <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                         <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                         <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                         <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                         <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                         <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                         <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                         <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 12 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.z.m,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_z_m.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.z.m &lt;- readRDS(&quot;ix_kern_z_m.rds&quot;)</span>
<span class="hl com"># ix.kern.z.m$t.test.diffs</span>
<span class="hl com"># ix.kern.z.m$graph</span>


<span class="hl com">#### Results for Figure A.1. Interflex: without covariates ####</span>

<span class="hl std">ix.kern.x.w</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.w,</span>
                         <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                         <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                         <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                         <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                         <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                         <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                         <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                         <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 2.078 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.x.w,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_x_w.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.x.w &lt;- readRDS(&quot;ix_kern_x_w.rds&quot;)</span>
<span class="hl com"># ix.kern.x.w$t.test.diffs</span>
<span class="hl com"># ix.kern.x.w$graph</span>

<span class="hl std">ix.kern.x.m</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.m,</span>
                         <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                         <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                         <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                         <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                         <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                         <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                         <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                         <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                         <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                         <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 0.706 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.x.m,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_x_m.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.x.m &lt;- readRDS(&quot;ix_kern_x_m.rds&quot;)</span>
<span class="hl com"># ix.kern.x.m$t.test.diffs</span>
<span class="hl com"># ix.kern.x.m$graph</span>

<span class="hl com">#### Results for Figure A.2. Interflex: with covariates and weights ####</span>

<span class="hl std">dt.w.wgt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt.w</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">select</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span><span class="hl str">&quot;wgt&quot;</span><span class="hl std">,</span><span class="hl str">&quot;country&quot;</span><span class="hl std">,v.z))</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">na.omit</span><span class="hl std">()</span>
</pre></div>
<div class="message"><pre class="knitr r">## Note: Using an external vector in selections is ambiguous.
## ℹ Use `all_of(v.z)` instead of `v.z` to silence this message.
## ℹ See &lt;https://tidyselect.r-lib.org/reference/faq-external-vector.html&gt;.
## This message is displayed once per session.
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl std">ix.kern.z.w.wgt</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.w.wgt,</span>
                             <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">Z</span><span class="hl std">=v.z,</span>
                             <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                             <span class="hl kwc">weights</span> <span class="hl std">=</span> <span class="hl str">&quot;wgt&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                             <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                             <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                             <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                             <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                             <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                             <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                             <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                             <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                             <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 2.378 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.z.w.wgt,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_z_w_wgt.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.z.w.wgt &lt;- readRDS(&quot;ix_kern_z_w_wgt.rds&quot;)</span>
<span class="hl com"># ix.kern.z.w.wgt$t.test.diffs</span>
<span class="hl com"># ix.kern.z.w.wgt$graph</span>

<span class="hl std">dt.m.wgt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt.m</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">select</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span><span class="hl str">&quot;wgt&quot;</span><span class="hl std">,</span><span class="hl str">&quot;country&quot;</span><span class="hl std">,v.z))</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">na.omit</span><span class="hl std">()</span>

<span class="hl std">ix.kern.z.m.wgt</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.m.wgt,</span>
                             <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">Z</span><span class="hl std">=v.z,</span>
                             <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                             <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                             <span class="hl kwc">weights</span> <span class="hl std">=</span> <span class="hl str">&quot;wgt&quot;</span><span class="hl std">,</span>
                             <span class="hl com"># cl=&quot;country&quot;,</span>
                             <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                             <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                             <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                             <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                             <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                             <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                             <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                             <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                             <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                             <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                             <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 12 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.z.m.wgt,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_z_m_wgt.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.z.m.wgt &lt;- readRDS(&quot;ix_kern_z_m_wgt.rds&quot;)</span>
<span class="hl std">ix.kern.z.m.wgt</span><span class="hl opt">$</span><span class="hl std">t.test.diffs</span>
</pre></div>
<div class="output"><pre class="knitr r">## $`1`
##          Diff Std.Err. z-score p-value CI_lower(95%) CI_upper(95%)
## 1 vs -1 0.073    0.036   2.009   0.045         0.002         0.143
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl std">ix.kern.z.m.wgt</span><span class="hl opt">$</span><span class="hl std">graph</span>
</pre></div>
</div><div class="rimage center"><img src="figure/03-analyses-Rhtmlauto-report-1.png" title="plot of chunk auto-report" alt="plot of chunk auto-report" class="plot" /></div><div class="rcode">
<div class="source"><pre class="knitr r"><span class="hl com">#### Results for Figure A.3. Interflex: with parents covariates ####</span>

<span class="hl std">ix.kern.zp.w</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.w,</span>
                          <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">Z</span><span class="hl std">=v.zp,</span>
                          <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                          <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                          <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                          <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                          <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                          <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                          <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                          <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                          <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 12 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.zp.w,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_zp_w.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.zp.w &lt;- readRDS(&quot;ix_kern_zp_w.rds&quot;)</span>
<span class="hl com"># ix.kern.zp.w$t.test.diffs</span>
<span class="hl com"># ix.kern.zp.w$graph</span>

<span class="hl std">ix.kern.zp.m</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.m,</span>
                          <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">Z</span><span class="hl std">=v.zp,</span>
                          <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                          <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                          <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                          <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                          <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                          <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                          <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                          <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                          <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 12 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.zp.m,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_zp_m.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.zp.m &lt;- readRDS(&quot;ix_kern_zp_m.rds&quot;)</span>
<span class="hl com"># ix.kern.zp.m$t.test.diffs</span>
<span class="hl com"># ix.kern.zp.m$graph</span>


<span class="hl com">#### Results for Figure A.5. Interflex: with job prestige ####</span>

<span class="hl std">ix.kern.zo.w</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.w,</span>
                          <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">Z</span><span class="hl std">=v.zo,</span>
                          <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                          <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                          <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                          <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                          <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                          <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                          <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                          <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                          <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 12 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.zo.w,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_zo_w.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.zp.w &lt;- readRDS(&quot;ix_kern_zp_w.rds&quot;)</span>
<span class="hl com"># ix.kern.zo.w$t.test.diffs</span>
<span class="hl com"># ix.kern.zo.w$graph</span>

<span class="hl std">ix.kern.zo.m</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.m,</span>
                          <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">Z</span><span class="hl std">=v.zo,</span>
                          <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                          <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                          <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                          <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                          <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                          <span class="hl kwc">cutoffs</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">6</span><span class="hl std">,</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">.9</span><span class="hl std">,</span><span class="hl num">6</span><span class="hl std">),</span>
                          <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                          <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                          <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 12 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.zo.m,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_zo_m.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.zp.m &lt;- readRDS(&quot;ix_kern_zp_m.rds&quot;)</span>
<span class="hl com"># ix.kern.zo.m$t.test.diffs</span>
<span class="hl com"># ix.kern.zo.m$graph</span>


<span class="hl com">#### Results for Figure A.6. Interflex: by job prestige household gap ####</span>

<span class="hl std">ix.kern.job.w</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.w,</span>
                          <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Job_diff&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">Z</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(v.zo[</span><span class="hl opt">-</span><span class="hl kwd">length</span><span class="hl std">(v.zo)],</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">),</span>
                          <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                          <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                          <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                          <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                          <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                          <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                          <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">10</span><span class="hl std">,</span><span class="hl num">10</span><span class="hl std">),</span>
                          <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 120.68 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.job.w,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_job_w.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.job.w$t.test.diffs</span>
<span class="hl com"># ix.kern.job.w$graph</span>

<span class="hl std">ix.kern.job.m</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.m,</span>
                          <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Job_diff&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">Z</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(v.zo[</span><span class="hl opt">-</span><span class="hl kwd">length</span><span class="hl std">(v.zo)],</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">),</span>
                          <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                          <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                          <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                          <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                          <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                          <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                          <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">bw.adaptive</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                          <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                          <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">10</span><span class="hl std">,</span><span class="hl num">10</span><span class="hl std">),</span>
                          <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Cross-validating bandwidth ... 
## #folds = 10
## Bandwidth = 106.67 
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ix.kern.job.m,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ix_kern_job_m.rds&quot;</span><span class="hl std">)</span>
<span class="hl com"># ix.kern.job.m$t.test.diffs</span>
<span class="hl com"># ix.kern.job.m$graph</span>


<span class="hl com">#### Results for Figure A.7. Interflex: varying bandwidth ####</span>

<span class="hl std">v.bw</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">.1</span><span class="hl std">,</span> <span class="hl num">.5</span><span class="hl std">,</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">,</span> <span class="hl num">5</span><span class="hl std">,</span> <span class="hl num">10</span><span class="hl std">)</span>
<span class="hl std">ls.w.bw</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">list</span><span class="hl std">()</span>
<span class="hl std">ls.m.bw</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">list</span><span class="hl std">()</span>

<span class="hl kwa">for</span> <span class="hl std">(b</span> <span class="hl kwa">in</span> <span class="hl std">v.bw[</span><span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">4</span><span class="hl std">]) {</span>

  <span class="hl kwd">print</span><span class="hl std">(</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;-------&quot;</span><span class="hl std">,b,</span><span class="hl str">&quot;-------&quot;</span><span class="hl std">))</span>

  <span class="hl std">ls.w.bw[[</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;bw&quot;</span><span class="hl std">,b)]]</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.w,</span>
                                         <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                                         <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                                         <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                                         <span class="hl kwc">Z</span><span class="hl std">=v.z,</span>
                                         <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                                         <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                                         <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                                         <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                                         <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                                         <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                                         <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                                         <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                                         <span class="hl kwc">bw</span><span class="hl std">=b,</span>
                                         <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                                         <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                                         <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
  <span class="hl std">)</span>

  <span class="hl std">ls.m.bw[[</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;bw&quot;</span><span class="hl std">,b)]]</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.m,</span>
                                         <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                                         <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                                         <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                                         <span class="hl kwc">Z</span><span class="hl std">=v.z,</span>
                                         <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                                         <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                                         <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                                         <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                                         <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                                         <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                                         <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                                         <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                                         <span class="hl kwc">bw</span><span class="hl std">=b,</span>
                                         <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                                         <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                                         <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
  <span class="hl std">)</span>
<span class="hl std">}</span>
</pre></div>
<div class="output"><pre class="knitr r">## [1] &quot;-------0.1-------&quot;
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## [1] &quot;-------0.5-------&quot;
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## [1] &quot;-------1-------&quot;
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## [1] &quot;-------3-------&quot;
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ls.w.bw,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ls_w_bw.rds&quot;</span><span class="hl std">)</span>
<span class="hl kwd">saveRDS</span><span class="hl std">(ls.m.bw,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ls_m_bw.rds&quot;</span><span class="hl std">)</span>

<span class="hl std">ls.w.bw.2</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">list</span><span class="hl std">()</span>
<span class="hl std">ls.m.bw.2</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">list</span><span class="hl std">()</span>

<span class="hl kwa">for</span> <span class="hl std">(b</span> <span class="hl kwa">in</span> <span class="hl std">v.bw[</span><span class="hl num">5</span><span class="hl opt">:</span><span class="hl num">6</span><span class="hl std">]) {</span>

  <span class="hl kwd">print</span><span class="hl std">(</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;-------&quot;</span><span class="hl std">,b,</span><span class="hl str">&quot;-------&quot;</span><span class="hl std">))</span>

  <span class="hl std">ls.w.bw.2[[</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;bw&quot;</span><span class="hl std">,b)]]</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.w,</span>
                                           <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                                           <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                                           <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                                           <span class="hl kwc">Z</span><span class="hl std">=v.z,</span>
                                           <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                                           <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                                           <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                                           <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                                           <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                                           <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                                           <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                                           <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                                           <span class="hl kwc">bw</span><span class="hl std">=b,</span>
                                           <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                                           <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                                           <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
  <span class="hl std">)</span>

  <span class="hl std">ls.m.bw.2[[</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;bw&quot;</span><span class="hl std">,b)]]</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">interflex</span><span class="hl std">(dt.m,</span>
                                           <span class="hl kwc">Y</span><span class="hl std">=</span><span class="hl str">&quot;Bad_job&quot;</span><span class="hl std">,</span>
                                           <span class="hl kwc">D</span><span class="hl std">=</span><span class="hl str">&quot;Treatment&quot;</span><span class="hl std">,</span>
                                           <span class="hl kwc">X</span><span class="hl std">=</span><span class="hl str">&quot;Edu_diff&quot;</span><span class="hl std">,</span>
                                           <span class="hl kwc">Z</span><span class="hl std">=v.z,</span>
                                           <span class="hl kwc">estimator</span><span class="hl std">=</span><span class="hl str">&quot;kernel&quot;</span><span class="hl std">,</span>
                                           <span class="hl kwc">FE</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;country&quot;</span><span class="hl std">),</span>
                                           <span class="hl kwc">parallel</span><span class="hl std">=v.parallel,</span>
                                           <span class="hl kwc">cores</span><span class="hl std">=v.cores,</span>
                                           <span class="hl kwc">nboots</span><span class="hl std">=v.boots,</span>
                                           <span class="hl kwc">neval</span><span class="hl std">=</span><span class="hl num">13</span><span class="hl std">,</span>
                                           <span class="hl kwc">na.rm</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                                           <span class="hl kwc">wald</span><span class="hl std">=</span><span class="hl num">TRUE</span><span class="hl std">,</span>
                                           <span class="hl kwc">bw</span><span class="hl std">=b,</span>
                                           <span class="hl kwc">quantile.eval</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span>
                                           <span class="hl kwc">diff.values</span><span class="hl std">=</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl std">,</span><span class="hl num">1</span><span class="hl std">),</span>
                                           <span class="hl kwc">predict</span><span class="hl std">=</span><span class="hl num">FALSE</span>
  <span class="hl std">)</span>
<span class="hl std">}</span>
</pre></div>
<div class="output"><pre class="knitr r">## [1] &quot;-------5-------&quot;
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## [1] &quot;-------10-------&quot;
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
## Baseline group not specified; choose treat = 0 as the baseline group. 
## Use a fully moderated model.
## Use adaptive bandwidth.
## Parallel computing with 4 cores...
## Bootstrapping ...
## 
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ls.w.bw.2,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ls_w_bw_2.rds&quot;</span><span class="hl std">)</span>
<span class="hl kwd">saveRDS</span><span class="hl std">(ls.m.bw.2,</span><span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ls_m_bw_2.rds&quot;</span><span class="hl std">)</span>



<span class="hl com">#### Results for Figure A.8. GAM: with covariates ####</span>

<span class="hl std">v.z.g</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">str_subset</span><span class="hl std">(v.z,</span><span class="hl str">&quot;_sq&quot;</span><span class="hl std">,</span><span class="hl kwc">negate</span><span class="hl std">=T)</span>
<span class="hl std">v.z.s</span> <span class="hl kwb">&lt;-</span> <span class="hl std">v.z.g[</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">3</span><span class="hl std">,</span><span class="hl num">7</span><span class="hl std">,</span><span class="hl num">8</span><span class="hl std">,</span><span class="hl num">9</span><span class="hl std">,</span><span class="hl num">12</span><span class="hl std">)]</span>
<span class="hl kwd">setdiff</span><span class="hl std">(v.z.g,v.z.s)</span>
</pre></div>
<div class="output"><pre class="knitr r">## [1] &quot;Minority&quot;           &quot;Immigrant&quot;          &quot;Domicile&quot;           &quot;Unemployed&quot;        
## [5] &quot;Unemployed_partner&quot; &quot;Interviewe_Female&quot;  &quot;Interfere&quot;
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl std">f.gam</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">as.formula</span><span class="hl std">(</span>
  <span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;Bad_job ~ s(Edu_diff) + s(Edu_diff, by=Treatment)&quot;</span><span class="hl std">,</span>
         <span class="hl str">&quot; + &quot;</span><span class="hl std">,</span> <span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;s(&quot;</span><span class="hl std">,v.z.s,</span><span class="hl str">&quot;, k=6)&quot;</span><span class="hl std">,</span> <span class="hl kwc">collapse</span><span class="hl std">=</span><span class="hl str">&quot; + &quot;</span><span class="hl std">),</span>
         <span class="hl str">&quot;+ as.factor(country)&quot;</span><span class="hl std">,</span>
         <span class="hl str">&quot; + &quot;</span><span class="hl std">,</span> <span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;s(Edu_diff, by=&quot;</span><span class="hl std">,v.z.g,</span><span class="hl str">&quot;, k=6)&quot;</span><span class="hl std">,</span> <span class="hl kwc">collapse</span><span class="hl std">=</span><span class="hl str">&quot; + &quot;</span><span class="hl std">)</span>
         <span class="hl std">)</span>
<span class="hl std">)</span>

<span class="hl std">gam.w</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">gam</span><span class="hl std">(f.gam,</span> <span class="hl kwc">data</span><span class="hl std">=dt.w)</span>
<span class="hl std">ls.gam.w</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">list</span><span class="hl std">(</span><span class="hl kwc">plot</span><span class="hl std">=</span><span class="hl kwd">plot</span><span class="hl std">(gam.w,</span><span class="hl kwc">select</span><span class="hl std">=</span><span class="hl num">2</span><span class="hl std">)[[</span><span class="hl num">2</span><span class="hl std">]],</span>
                 <span class="hl kwc">summary</span><span class="hl std">=</span><span class="hl kwd">summary</span><span class="hl std">(gam.w))</span>
</pre></div>
</div><div class="rimage center"><img src="figure/03-analyses-Rhtmlauto-report-2.png" title="plot of chunk auto-report" alt="plot of chunk auto-report" class="plot" /></div><div class="rcode">
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ls.gam.w,</span> <span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ls_gam_w.rds&quot;</span><span class="hl std">)</span>

<span class="hl std">gam.m</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">gam</span><span class="hl std">(f.gam,</span> <span class="hl kwc">data</span><span class="hl std">=dt.m)</span>
<span class="hl std">ls.gam.m</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">list</span><span class="hl std">(</span><span class="hl kwc">plot</span><span class="hl std">=</span><span class="hl kwd">plot</span><span class="hl std">(gam.m,</span><span class="hl kwc">select</span><span class="hl std">=</span><span class="hl num">2</span><span class="hl std">)[[</span><span class="hl num">2</span><span class="hl std">]],</span>
                 <span class="hl kwc">summary</span><span class="hl std">=</span><span class="hl kwd">summary</span><span class="hl std">(gam.m))</span>
</pre></div>
</div><div class="rimage center"><img src="figure/03-analyses-Rhtmlauto-report-3.png" title="plot of chunk auto-report" alt="plot of chunk auto-report" class="plot" /></div><div class="rcode">
<div class="source"><pre class="knitr r"><span class="hl kwd">saveRDS</span><span class="hl std">(ls.gam.m,</span> <span class="hl kwc">file</span><span class="hl std">=</span><span class="hl str">&quot;ls_gam_m.rds&quot;</span><span class="hl std">)</span>
</pre></div>
</div></div>

  <p>The R session information (including the OS info, R version and all
    packages used):</p>

<div class="chunk" id="session-info"><div class="rcode"><div class="source"><pre class="knitr r">    <span class="hl kwd">sessionInfo</span><span class="hl std">()</span>
</pre></div>
<div class="output"><pre class="knitr r">## R version 4.0.3 (2020-10-10)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Catalina 10.15.7
## 
## Matrix products: default
## BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] interflex_1.1.4   devtools_2.3.2    usethis_2.0.0     mgcv_1.8-33      
##  [5] nlme_3.1-151      swfscMisc_1.3     sjmisc_2.8.6      sjlabelled_1.1.7 
##  [9] forcats_0.5.1     stringr_1.4.0     dplyr_1.0.4       purrr_0.3.4      
## [13] readr_1.4.0       tidyr_1.1.2       tibble_3.0.6      ggplot2_3.3.3    
## [17] tidyverse_1.3.0   lfe_2.8-6         Matrix_1.3-2      estimatr_0.30.2  
## [21] data.table_1.13.6 pacman_0.5.1      knitr_1.31       
## 
## loaded via a namespace (and not attached):
##   [1] readxl_1.3.1         backports_1.2.1      Hmisc_4.4-2          plyr_1.8.6          
##   [5] splines_4.0.3        digest_0.6.27        htmltools_0.5.1.1    foreach_1.5.1       
##   [9] checkmate_2.0.0      magrittr_2.0.1       memoise_2.0.0        cluster_2.1.0       
##  [13] tensor_1.5           doParallel_1.0.16    remotes_2.2.0        recipes_0.1.15      
##  [17] modelr_0.1.8         gower_0.2.2          sandwich_3.0-0       prettyunits_1.1.1   
##  [21] jpeg_0.1-8.1         colorspace_2.0-0     rvest_0.3.6          haven_2.3.1         
##  [25] xfun_0.20            callr_3.5.1          crayon_1.4.0         jsonlite_1.7.2      
##  [29] lme4_1.1-26          spatstat_1.64-1      spatstat.data_1.7-0  survival_3.2-7      
##  [33] zoo_1.8-8            iterators_1.0.13     glue_1.4.2           polyclip_1.10-0     
##  [37] gtable_0.3.0         ipred_0.9-9          emmeans_1.5.4        pkgbuild_1.2.0      
##  [41] maps_3.3.0           abind_1.4-5          scales_1.1.1         mvtnorm_1.1-1       
##  [45] DBI_1.1.1            Rcpp_1.0.6           htmlTable_2.1.0      xtable_1.8-4        
##  [49] gridGraphics_0.5-1   foreign_0.8-81       Formula_1.2-4        stats4_4.0.3        
##  [53] lava_1.6.8.1         prodlim_2019.11.13   htmlwidgets_1.5.3    httr_1.4.2          
##  [57] RColorBrewer_1.1-2   ellipsis_0.3.1       farver_2.0.3         pkgconfig_2.0.3     
##  [61] nnet_7.3-15          dbplyr_2.1.0         deldir_0.2-9         caret_6.0-86        
##  [65] labeling_0.4.2       ggplotify_0.0.5      tidyselect_1.1.0     rlang_0.4.10        
##  [69] reshape2_1.4.4       munsell_0.5.0        cellranger_1.1.0     tools_4.0.3         
##  [73] cachem_1.0.1         cli_2.3.0            generics_0.1.0       broom_0.7.4         
##  [77] evaluate_0.14        fastmap_1.1.0        yaml_2.2.1           arm_1.11-2          
##  [81] goftest_1.2-2        ModelMetrics_1.2.2.2 processx_3.4.5       fs_1.5.0            
##  [85] xml2_1.3.2           pcse_1.9.1.1         compiler_4.0.3       rstudioapi_0.13     
##  [89] png_0.1-7            testthat_3.0.1       spatstat.utils_2.0-0 mapdata_2.3.0       
##  [93] reprex_1.0.0         statmod_1.4.35       stringi_1.5.3        highr_0.8           
##  [97] ps_1.5.0             desc_1.2.0           lattice_0.20-41      nloptr_1.2.2.2      
## [101] vctrs_0.3.6          pillar_1.4.7         lifecycle_0.2.0      BiocManager_1.30.10 
## [105] lmtest_0.9-38        estimability_1.3     insight_0.12.0       latticeExtra_0.6-29 
## [109] R6_2.5.0             bookdown_0.21        gridExtra_2.3        sessioninfo_1.1.1   
## [113] Lmoments_1.3-1       codetools_0.2-18     boot_1.3-26          MASS_7.3-53         
## [117] assertthat_0.2.1     pkgload_1.1.0        rprojroot_2.0.2      withr_2.4.1         
## [121] parallel_4.0.3       hms_1.0.0            grid_4.0.3           rpart_4.1-15        
## [125] timeDate_3043.102    minqa_1.2.4          coda_0.19-4          class_7.3-18        
## [129] rmarkdown_2.6        rvcheck_0.1.8        pROC_1.17.0.1        lubridate_1.7.9.2   
## [133] base64enc_0.1-3
</pre></div>
<div class="source"><pre class="knitr r">    <span class="hl kwd">Sys.time</span><span class="hl std">()</span>
</pre></div>
<div class="output"><pre class="knitr r">## [1] &quot;2021-02-12 08:59:18 CET&quot;
</pre></div>
</div></div>


</body>
</html>
